<!DOCTYPE html>
<head xmlns:v-bind="http://www.w3.org/1999/xhtml" >
    <meta charset="UTF-8">
    <title>demo18_3-axios Api</title>
  <script src="./js/vue.min.js"></script>
  <script src="./js/vue-router.js"></script>
  <script src="./js/axios.min.js"></script>
</head>

<body>

   <div id="app">
      <h1>网站列表</h1>
     <div v-for=" site in info">
       {{site.name}}
     </div>
   </div>

</body>

<script type="application/javascript">
   axios(config);
   //发送Post请求
    axios({
      method: 'POST',
      url: '/user/12345',
      data: {
        firstName: 'fred',
        lastName: 'tom'
      }
    });
    //请求远程图片
  axios({
    method: 'GET',
    url: 'http://bit.ly/2mTM3nY',
    responseType: 'stream'
  }).then(function (res) {
    res.data.pipe(fs.createWriteStream('test.jpg'))
  });

  //发送GET请求
  axios('/user/12345')

/*
   axios(url[,config]);
   axios.request(config)
   axios.get(url[, config])
   axios.delete(url[, config])
   axios.head(url[, config])
   axios.post(url[, data[, config]])
   axios.put(url[, data[, config]])
   axios.patch(url[, data[, config]])*/
//创建axios实例
  axios.create([config]);
  const instance = axios.create({
    baseURL: '网址',
    timeout: 1000,
    headers: {'X-Custom-Header': 'foobar'}
  })
  //实例方法
/*
   axios#request(config)
   axios#get(url[, config])
   axios#delete(url[, config])
   axios#head(url[, config])
   axios#post(url[, data[, config]])
   axios#put(url[, data[, config]])
   axios#patch(url[, data[, config]])
   */

</script>
</html>
